package com.dgh.school.controller;

import com.dgh.school.bean.Affair;
import com.dgh.school.common.R;
import com.dgh.school.service.AffairService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class AffairController {
    @Autowired
    private AffairService affairService;

    @RequestMapping("/affair")
    public R selectByPage(int pageNum, int pageSize){
        try {
            return affairService.selectByPage(pageNum,pageSize);
        } catch (Exception e) {
            return R.error();
        }
    }

    @RequestMapping("/affair/delete")
    public R deleteSchedule(int id){
        try {
            affairService.deleteAffair(id);
            return R.ok();
        } catch (Exception e) {
            return R.error();
        }
    }

    @RequestMapping("/affair/modify")
    public R modify(Affair affair){
        try {
            affairService.updateData(affair);
//            System.out.println(schedule);
            return R.ok();
        } catch (Exception e) {
            return R.error();
        }
    }
}
